class ApiResponse<T> {
  final T? data;
  final int statusCode;
  final String message;
  final bool success;
  final Map<String, dynamic>? headers;

  ApiResponse({
    this.data,
    required this.statusCode,
    required this.message,
    required this.success,
    this.headers,
  });

  factory ApiResponse.success(T data, {int statusCode = 200, Map<String, dynamic>? headers}) {
    return ApiResponse(
      data: data,
      statusCode: statusCode,
      message: 'Success',
      success: true,
      headers: headers,
    );
  }

  factory ApiResponse.error(String message, {int statusCode = 500, Map<String, dynamic>? headers}) {
    return ApiResponse(
      data: null,
      statusCode: statusCode,
      message: message,
      success: false,
      headers: headers,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'data': data,
      'statusCode': statusCode,
      'message': message,
      'success': success,
      'headers': headers,
    };
  }
}